package com.shengdong.water.code.adapter

import com.shengdong.water.R
import com.shengdong.water.code.base.BaseRecyclerAdapter
import com.shengdong.water.code.bean.NotifyMsg
import com.shengdong.water.databinding.ItemNotifyBinding

class NotifyMsgAdapter : BaseRecyclerAdapter<NotifyMsg, ItemNotifyBinding>() {

    override fun getLayoutId() = R.layout.item_notify

    override fun bindData(binding: ItemNotifyBinding, item: NotifyMsg, position: Int) {
        binding.item = item

        // 可以在这里添加额外的绑定逻辑
        binding.itemTitle.text = item.title
        binding.itemTime.text = item.createTime
        binding.itemDesc.text = item.content

        binding.executePendingBindings()
    }

    // 如果User有唯一ID，可以重写这个方法提高效率
    override fun areItemsTheSame(oldItem: NotifyMsg, newItem: NotifyMsg): Boolean {
        return oldItem.id == newItem.id
    }

    // 内容比较可以更精确
    override fun areContentsTheSame(oldItem: NotifyMsg, newItem: NotifyMsg): Boolean {
        return oldItem.imageUrl == newItem.imageUrl
    }


}